package com.daodaofun.util;

import java.util.ArrayList;
import java.util.List;

/**
 * 分页助手
 * @param <T>
 */
public class Page<T> {


    /**
     * 页码大小
     */
    private int pageSize;

    /**
     * 当前页码
     */
    private int pageNum;

    /**
     * 总条数
     */
    private long total;

    /**
     * 总页数
     */
    private int pages;

    private List<T> list = new ArrayList<>();

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public int getPages() {
        return total % pageSize == 0 ? (int) (total / pageSize) :(int)(total / pageSize + 1);
    }



    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }
}
